import category from './category.js'

class Utils {
  static getTypeName(chatType) {
    let ret = '普通对话'
    category.forEach(c1 => {
      c1.categoryDetail.forEach(c2 => {
        if (chatType === c2.chatType)
        ret = c2.typeName
        return
      })
    })
    return ret
  }
  static getTypeImage(chatType) {
    let ret = '/assets/images/brain_logo.png'
    category.forEach(c1 => {
      c1.categoryDetail.forEach(c2 => {
        if (chatType === c2.chatType)
        ret = c2.imgSrc
        return
      })
    })
    return ret
  }
  static getCategoryName() {
    const ret = []
    category.forEach(c1 => {
      ret.push(c1.categoryName)
    })
    return ret
  }
  static truncateString(str) {
    const truncateLen = 14
    if (str.length > truncateLen) {
        return str.slice(0, truncateLen) + '...';
    } else {
        return str;
    }
}
}

export default Utils